SQlite源码分析

非调试情况

#ifndef SQLITE_MUTEX_OMIT//非调试的情况运行

#ifndef SQLITE_DEBUG
/*
** Stub routines for all mutex methods.
//所有互斥体实现的基本函数
**
** This routines provide no mutual exclusion or error checking.
*/
static int noopMutexInit(void){ return SQLITE_OK; }
static int noopMutexEnd(void){ return SQLITE_OK; }
static sqlite3_mutex *noopMutexAlloc(int id){
  UNUSED_PARAMETER(id);// 指针转化(void)(id)
  return (sqlite3_mutex*)8; //默认返回8
}
static void noopMutexFree(sqlite3_mutex *p){ UNUSED_PARAMETER(p); return; }
static void noopMutexEnter(sqlite3_mutex *p){ UNUSED_PARAMETER(p); return; }
static int noopMutexTry(sqlite3_mutex *p){
  UNUSED_PARAMETER(p);
  return SQLITE_OK;
}
static void noopMutexLeave(sqlite3_mutex *p){ UNUSED_PARAMETER(p); return; }

sqlite3_mutex_methods const *sqlite3NoopMutex(void){
  static const sqlite3_mutex_methods sMutex = {
    noopMutexInit,
    noopMutexEnd,
    noopMutexAlloc,
    noopMutexFree,
    noopMutexEnter,
    noopMutexTry,
    noopMutexLeave,

    0, // int (*xMutexHeld)(sqlite3_mutex *);
    0,// int (*xMutexNotheld)(sqlite3_mutex *);
  };

  return &sMutex;//返回分配的互斥体
}
#endif /* !SQLITE_DEBUG */

#ifdef SQLITE_DEBUG